import 'package:flutter/material.dart';

class HomeActivity extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => HomeActivityState();
}

class HomeActivityState extends State<HomeActivity> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Column(
          children: <Widget>[
            Container(
              height: 200.0,
              color: Colors.blue,
            ),
            GridView.count(
              primary: false,
              padding: EdgeInsets.all(8.0),
              shrinkWrap: true,
              mainAxisSpacing: 8.0,
              crossAxisSpacing: 8.0,
              crossAxisCount: 2,
              children: buildGridTileList(5),
            ),
          ],
        ),
      ),
    );
  }

  List<Widget> buildGridTileList(int number) {
    List<Widget> widgetList = new List();
    for (int i = 0; i < number; i++) {
      widgetList.add(getItemWidget());
    }
    return widgetList;
  }

  String url =
      "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=495625508,"
      "3408544765&fm=27&gp=0.jpg";

  Widget getItemWidget() {
    //BoxFit 可设置展示图片时 的填充方式
    return new Image(image: new NetworkImage(url), fit: BoxFit.cover);
  }
}
